<template>
  <div class="comment-page f-c">
    <div class="header">
      <div class="title">专家评审意见</div>
    </div>
    <div class="table-box">
      <el-table
        height="300px"

        :data="professorList"
        element-loading-spinner="el-icon-loading"
        element-loading-background="rgba(255, 255, 255, 0.8)"
      >
        <el-table-column v-for="item in columns1" :key="item.prop" :prop="item.prop" :label="item.label" align="center" />
        <el-table-column label="评审意见">
          <template slot-scope="scope">
            <FileView v-if="scope.row.method === 1" style="margin-bottom: 0" />
            <span v-else-if="scope.row.method === 2">{{ scope.row.reviewFile }}</span>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="page-box">
      <el-pagination
        background
        :current-page="pageNo1"
        :page-sizes="pageSizes"
        :page-size="pageSize1"
        layout="total, sizes, prev, pager, next, jumper"
        :total="totalSize1"
        @size-change="changePageSize1"
        @current-change="changePageNo1"
      />
    </div>

    <div class="header">
      <div class="title" style="margin-top: 24px">单位评审意见</div>
    </div>
    <div class="table-box">
      <el-table
        height="300px"

        :data="deptList"
        element-loading-spinner="el-icon-loading"
        element-loading-background="rgba(255, 255, 255, 0.8)"
      >
        <el-table-column
          v-for="item in columns2"
          :key="item.prop"
          :prop="item.prop"
          :label="item.label"
          align="center"
        />
        <el-table-column label="评审意见">
          <template slot-scope="scope">
            <FileView v-if="scope.row.method === 1" style="margin-bottom: 0" />
            <span v-else-if="scope.row.method === 2">{{ scope.row.reviewFile }}</span>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <div class="page-box">
      <el-pagination
        background
        :current-page="pageNo2"
        :page-sizes="pageSizes"
        :page-size="pageSize2"
        layout="total, sizes, prev, pager, next, jumper"
        :total="totalSize2"
        @size-change="changePageSize2"
        @current-change="changePageNo2"
      />
    </div>
    <div class="header">
      <div class="title" style="margin-top: 24px">会议意见</div>
    </div>
    <SubmitForm
      :rule-form="ruleForm"
      :rules="rules"
      :form-list="formList"
      @save="onSave"
    />
  </div>
</template>

<script>
import { http } from '@/api'

export default {
  name: 'CommentList',
  props: {
    currentDetail: Object
  },
  data() {
    return {
      dialogValue: false,
      ruleForm: {
        opinion: ''
      },
      rules: {
        opinion: [{ required: true, message: '不能为空' }]
      },
      formList: [
        {
          key: 'opinion',
          name: 'input',
          label: '会议意见',
          type: 'textarea',
          colSpan: 12
        }
      ],
      professorList: [],
      deptList: [],
      columns1: [
        { prop: 'projectName', label: '项目名称' },
        { prop: 'expertName', label: '专家姓名' },
        { prop: 'industryName', label: '部门' }
      ],
      columns2: [
        { prop: 'projectName', label: '项目名称' },
        { prop: 'realName', label: '参会人员姓名' },
        { prop: 'departName', label: '部门' }
      ],
      pageNo1: 1,
      pageSize1: 10,
      pageSizes: [10, 20, 30, 40, 50],
      totalSize1: 0,
      pageNo2: 1,
      pageSize2: 10,
      totalSize2: 0
    }
  },
  created() {
    this.getList1()
    this.getList2()
  },
  methods: {
    getList1() {
      http.meeting_comment.professor_page({
        projectId: this.currentDetail.id,
        pageNo: this.pageNo1,
        pageSize: this.pageSize1
      }).then(res => {
        this.totalSize1 = res.data.total
        this.professorList = res.data.records
      })
    },
    getList2() {
      http.meeting_comment.dept_page({
        projectId: this.currentDetail.id,
        pageNo: this.pageNo2,
        pageSize: this.pageSize2
      }).then(res => {
        console.log(res);
        this.totalSize2 = res.data.total
        this.deptList = res.data.records
        console.log(this.deptList);
      })
    },

    changePageNo1(pageNo) {
      this.pageNo1 = pageNo
      this.getList1()
    },
    changePageSize1(pageSize) {
      this.pageSize1 = pageSize
      this.pageNo1 = 1
      this.getList1()
    },
    changePageNo2(pageNo) {
      this.pageNo2 = pageNo
      this.getList2()
    },
    changePageSize2(pageSize) {
      this.pageSize2 = pageSize
      this.pageNo2 = 1
      this.getList2()
    },
    onSave() {
      http.meeting_comment.create({
          meetingIdea: this.ruleForm.opinion,
          id: this.currentDetail.id
      }).then(res => {
        this.$message.success(res.msg)
        
        this.ruleForm = {
          opinion: ''
        }
        this.$emit("success")
      })
    }
  }
}
</script>

<style scoped lang="scss">
.comment-page {
    height: 100%;overflow:auto;
}
</style>
